package ua.com.bitlab.figures;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * User: Roman Boyarsky
 * Date: 4/10/12
 */
public class Square implements Figure {

    private static final Logger log = LoggerFactory.getLogger(Square.class);

    private int coordinateX;
    private int coordinateY;
    private int width;
    private int height;

    public Square(int coordinateX, int coordinateY, int width) {
        this.coordinateX = coordinateX;
        if (this.coordinateX < 0) {
            this.coordinateX *= (-1);
        }
        this.coordinateY = coordinateY;
        if (this.coordinateY < 0) {
            this.coordinateY *= (-1);
        }
        this.width = width;
        if (this.width < 0) {
            this.width *= (-1);
        }
        this.height = width;
        if (this.height < 0) {
            this.height *= (-1);
        }

        log.debug("Creating square with coordinates: x=" + this.coordinateX + ", y="
                + this.coordinateY + ", width=" + this.width + ", height=" + this.height);
    }

    public int getCoordinateX() {
        return coordinateX;
    }

    public int getCoordinateY() {
        return coordinateY;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    @Override
    public void rotate(int angle) {
        //todo: implement rotation of square!
        log.debug("Rotating square on " + angle + "degrees");
    }

    @Override
    public void move(int newСoordinateX, int newСoordinateY) {
        coordinateX = newСoordinateX;
        coordinateY = newСoordinateY;

        log.debug("Changing square position on x=" + coordinateX + ", y=" + coordinateY);
    }

    @Override
    public void resize(int modifier) {
        width *= modifier;
        height *= modifier;

        log.debug("New width and height of square are: [" + width + "], [" + height + "]");
    }
}
